package org.grill.clovercash.accounts;


import java.math.BigDecimal;

import junit.framework.TestCase;

public class SumRangeFinderTest extends TestCase {
	public void testSimple() {
		int[] startEnd;
		startEnd = new SumRangeFinder().find(new BigDecimal(1.0), new BigDecimal[] { new BigDecimal(0.2), new BigDecimal(1.0), new BigDecimal(0.2)});
		assertEquals(1, startEnd[0]);
		assertEquals(1, startEnd[1]);

		startEnd = new SumRangeFinder().find(new BigDecimal("1.4"), new BigDecimal[] { new BigDecimal("0.2"), new BigDecimal("1.0"), new BigDecimal("0.2")});
		assertEquals(0, startEnd[0]);
		assertEquals(2, startEnd[1]);
		
		startEnd = new SumRangeFinder().find(new BigDecimal("1.4"), new BigDecimal[] { new BigDecimal("0.2"), new BigDecimal("1.0"), new BigDecimal("0.2"), 
			new BigDecimal("0.2"), new BigDecimal("-0.2")});
		assertEquals(0, startEnd[0]);
		assertEquals(4, startEnd[1]);

		startEnd = new SumRangeFinder().find(new BigDecimal("1.4"), new BigDecimal[] { new BigDecimal("0.5"), new BigDecimal("1.0"), new BigDecimal("0.2"), 
			new BigDecimal("0.2"), new BigDecimal("0.2")});
		assertEquals(1, startEnd[0]);
		assertEquals(3, startEnd[1]);

		startEnd = new SumRangeFinder().find(new BigDecimal("1.33"), new BigDecimal[] { new BigDecimal("0.5"), new BigDecimal("1.0"), new BigDecimal("0.2"), 
			new BigDecimal("0.2"), new BigDecimal("0.2")});
		assertEquals(-1, startEnd[0]);
		assertEquals(-1, startEnd[1]);

	}
}
